<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/2
 * Time: 16:20
 */


namespace app\index\controller;

use think\Db;
use think\View;
use think\Controller;


class Comment extends Controller
{
    public function comment()
    {
        $providerId = getProviderId();
        $serviceId = $_GET['serviceId'];
        $data =Db::name('provider_review pr')
            ->join('member','member.memberId=pr.memberId')
            ->where('pr.providerId',$providerId)->where('pr.serviceId',$serviceId)->limit(20)->select();
        foreach ($data as $key => $value) {
            $area = Db::name('area')->where('areaId', $value['areaId'])->find();
            $parent = Db::name('area')->where('areaId', $area['parentId'])->find();
            $data[$key]['area'] = $area['areaName'];
            $data[$key]['parea'] = $parent['areaName'];
        }
        $this->view->assign('data',$data);
        //获取评价条数
        $reviewNum=Db::name('provider_review')->where('serviceId',$serviceId)->where('providerId',getProviderId())->count();
        $this->view->assign('reviewNum', $reviewNum);
        return view('comment');
    }
    public function addComment()
    {
        return view('addcomment');
    }

}